package io.bba.boot.app.controller;

import io.bba.boot.app.dto.CrawlerUrlDto;
import io.bba.boot.framework.page.Paging;
import io.bba.boot.framework.response.ApiResult;
import io.bba.boot.app.query.AppCrawlerUrlQuery;
import io.bba.boot.app.service.CrawlerUrlService;
import io.bba.boot.app.vo.AppCrawlerUrlVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * App采集记录 控制器
 *
 * @author zs
 * @since 2024-03-19
 */
@Slf4j
@RestController
@Tag(name = "App采集记录")
@RequestMapping("/app/crawlerUrl")
public class AppCrawlerUrlController {

    @Autowired
    private CrawlerUrlService crawlerUrlService;

    /**
     * 获取App采集记录详情
     *
     * @param id
     * @return
     * @throws Exception
     */
    @Operation(summary = "获取App采集记录详情")
    @PostMapping("/getAppCrawlerUrl/{id}")
    public ApiResult<AppCrawlerUrlVo> getAppCrawlerUrl(@PathVariable Long id) {
        log.info("获取App采集记录详情：{}", id);
        AppCrawlerUrlVo appCrawlerUrlVo = crawlerUrlService.getAppCrawlerUrlById(id);
        return ApiResult.success(appCrawlerUrlVo);
    }

    /**
     * 获取App采集记录分页列表
     *
     * query
     * @return
     * @throws Exception
     */
    @Operation(summary = "获取App采集记录分页列表")
    @PostMapping("/getAppCrawlerUrlPage")
    public ApiResult<AppCrawlerUrlVo> getAppCrawlerUrlPage(@Valid @RequestBody AppCrawlerUrlQuery query) {
        log.info("获取App采集记录分页列表：{}", query);
        Paging<AppCrawlerUrlVo> paging = crawlerUrlService.getAppCrawlerUrlPage(query);
        return ApiResult.success(paging);
    }
}
